package com.example.demo.configuration;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SenderConf4 {

	@Bean(name = "Amessage")
	public Queue AMessage() {
		return new Queue("fanout.A");
	}

	@Bean(name = "Bmessage")
	public Queue BMessage() {
		return new Queue("fanout.B");
	}

	@Bean(name = "Cmessage")
	public Queue CMessage() {
		return new Queue("fanout.C");
	}

	@Bean
	DirectExchange directExchange() {
		return new DirectExchange("directExchange");// 配置广播路由器
	}

	@Bean
	Binding bindingExchangeA(@Qualifier("Amessage") Queue AMessage, DirectExchange directExchange) {
		return BindingBuilder.bind(AMessage).to(directExchange).with("fanout.A");
	}

	@Bean
	Binding bindingExchangeB(@Qualifier("Bmessage") Queue BMessage, DirectExchange directExchange) {
		return BindingBuilder.bind(BMessage).to(directExchange).with("fanout.B");
	}

	@Bean
	Binding bindingExchangeC(@Qualifier("Cmessage") Queue CMessage, DirectExchange directExchange) {
		return BindingBuilder.bind(CMessage).to(directExchange).with("fanout.C");
	}
}